/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, {
/******/ 				configurable: false,
/******/ 				enumerable: true,
/******/ 				get: getter
/******/ 			});
/******/ 		}
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _storage = __webpack_require__(1);

var _storage2 = _interopRequireDefault(_storage);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
    value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
                                                                                                                                                                                                                                                                               * Created by Administrator on 2017/7/20.
                                                                                                                                                                                                                                                                               */


var _base = __webpack_require__(2);

var _base2 = _interopRequireDefault(_base);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var ty_throw_msg = function ty_throw_msg(ty_msg) {
    return {
        developer: 'yangBin',
        error: ty_msg
    };
};
var ty_type_arr = ['sessionStorage', 'localStorage'];
var storage = {};
(function (window, undefined) {
    function getStorage(ty_type) {
        return function (ty_string, ty_status) {
            if (typeof ty_string !== 'string') {
                throw new ty_throw_msg('操作的key只能是字符串');
                return;
            }
            var ty_get_val = window[ty_type].getItem(ty_string);
            ty_get_val = ty_status === true ? _base2.default.decode(ty_get_val) : ty_get_val;
            try {
                ty_get_val = JSON.parse(ty_get_val);
            } catch (err) {
                // throw new ty_throw_msg(err);
            }
            return ty_get_val;
        };
    }
    function setStorage(ty_type) {
        return function (ty_key, ty_obj, ty_status) {
            if (typeof ty_key !== 'string') {
                throw new ty_throw_msg('操作的key只能是字符串');
                return;
            }
            ty_obj = (typeof ty_obj === 'undefined' ? 'undefined' : _typeof(ty_obj)) === 'object' ? JSON.stringify(ty_obj) : ty_obj === null || ty_obj === undefined ? '' : ty_obj;
            ty_obj = ty_status === true ? _base2.default.encode(ty_obj) : ty_obj;
            window[ty_type].setItem(ty_key + '', ty_obj);
        };
    }
    function removeStorage(ty_type) {
        return function (ty_arr) {
            if (typeof ty_arr === 'string') {
                window[ty_type].removeItem(ty_arr);
            } else if (Object.prototype.toString.call(ty_arr) === '[object Array]') {
                for (var ini = 0; ini < ty_arr.length; ini++) {
                    window[ty_type].removeItem(ty_arr[ini]);
                }
            } else if (typeof ty_arr === 'undefined' || ty_arr === null) {
                window[ty_type].clear();
            } else {
                throw new ty_throw_msg('参数只能是数组、字符串、空');
            }
        };
    }
    function buildCookie(window, document, cookie) {
        return {
            set: function set(ty_name, ty_val, ty_time) {
                ty_time = typeof ty_time !== 'number' ? 1000 : ty_time;
                var ty_exp = new Date();
                ty_exp.setTime(ty_exp.getTime() + ty_time * 60 * 60 * 1000);
                if (typeof ty_name !== 'string') {
                    throw new ty_throw_msg('操作的key只能是字符串');
                    return;
                }
                ty_val = (typeof ty_val === 'undefined' ? 'undefined' : _typeof(ty_val)) === 'object' ? JSON.stringify(ty_val) : ty_val === null || ty_val === undefined ? '' : ty_val;
                ty_val = arguments[arguments.length - 1] === true ? _base2.default.encode(ty_val) : ty_val;
                window[document][cookie] = ty_name + "=" + escape(ty_val) + ";expires=" + ty_exp.toGMTString();
            },

            //读取cookies
            get: function get(ty_name, ty_status) {
                if (typeof ty_name !== "string") {
                    throw new ty_throw_msg('操作的key只能是字符串');
                    return;
                }
                if (window[document][cookie].length > 0) {
                    var ty_start = window[document][cookie].indexOf(ty_name + "=");
                    if (ty_start != -1) {
                        ty_start = ty_start + ty_name.length + 1;
                        var ty_end = window[document][cookie].indexOf(";", ty_start);
                        if (ty_end == -1) ty_end = window[document][cookie].length;
                        var getValue = unescape(window[document][cookie].substring(ty_start, ty_end));
                        getValue = ty_status === true ? _base2.default.decode(getValue) : getValue;
                        try {
                            getValue = JSON.parse(getValue);
                        } catch (m) {}

                        return getValue;
                    }
                }
                return false;
            },

            //删除cookies
            remove: function remove(ty_name) {
                var ty_exp = new Date();
                ty_exp.setTime(ty_exp.getTime() - 10);
                if (typeof ty_name === 'string') {
                    var ty_val = this.get(ty_name);
                    if (ty_val !== false && ty_val !== null) {
                        window[document][cookie] = ty_name + "=" + ty_val + ";expires=" + ty_exp.toGMTString();
                    }
                } else if (Object.prototype.toString.call(ty_name) === '[object Array]') {
                    ty_name.map(function (ty_item) {
                        var ty_val = this.get(ty_item);
                        if (ty_val !== false && ty_val !== null) {
                            window[document][cookie] = ty_name + "=" + ty_val + ";expires=" + ty_exp.toGMTString();
                        }
                    });
                } else {
                    throw new ty_throw_msg('参数只能是数组、字符串、空');
                }
            }
        };
    }
    ty_type_arr.map(function (ty_item) {
        storage[ty_item] = {};
        storage[ty_item]['get'] = getStorage(ty_item);
        storage[ty_item]['set'] = setStorage(ty_item);
        storage[ty_item]['remove'] = removeStorage(ty_item);
    });
    storage['cookie'] = new buildCookie(window, 'document', 'cookie');
})(window, undefined);
exports.default = storage;

/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
    value: true
});

var BASE64_MAPPING = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'];

/**
 *ascii convert to binary
 */
var _toBinary = function _toBinary(ascii) {
    var binary = new Array();
    while (ascii > 0) {
        var b = ascii % 2;
        ascii = Math.floor(ascii / 2);
        binary.push(b);
    }
    /*
     var len = binary.length;
     if(6-len > 0){
     for(var i = 6-len ; i > 0 ; --i){
     binary.push(0);
     }
     }*/
    binary.reverse();
    return binary;
};

/**
 *binary convert to decimal
 */
var _toDecimal = function _toDecimal(binary) {
    var dec = 0;
    var p = 0;
    for (var i = binary.length - 1; i >= 0; --i) {
        var b = binary[i];
        if (b == 1) {
            dec += Math.pow(2, p);
        }
        ++p;
    }
    return dec;
};

/**
 *unicode convert to utf-8
 */
var _toUTF8Binary = function _toUTF8Binary(c, binaryArray) {
    var mustLen = 8 - (c + 1) + (c - 1) * 6;
    var fatLen = binaryArray.length;
    var diff = mustLen - fatLen;
    while (--diff >= 0) {
        binaryArray.unshift(0);
    }
    var binary = [];
    var _c = c;
    while (--_c >= 0) {
        binary.push(1);
    }
    binary.push(0);
    var i = 0,
        len = 8 - (c + 1);
    for (; i < len; ++i) {
        binary.push(binaryArray[i]);
    }

    for (var j = 0; j < c - 1; ++j) {
        binary.push(1);
        binary.push(0);
        var sum = 6;
        while (--sum >= 0) {
            binary.push(binaryArray[i++]);
        }
    }
    return binary;
};

var ybBase64 = {
    /**
     *BASE64 Encode
     */
    encode: function encode(str) {
        var base64_Index = [];
        var binaryArray = [];
        for (var i = 0, len = str.length; i < len; ++i) {
            var unicode = str.charCodeAt(i);
            var _tmpBinary = _toBinary(unicode);
            if (unicode < 0x80) {
                var _tmpdiff = 8 - _tmpBinary.length;
                while (--_tmpdiff >= 0) {
                    _tmpBinary.unshift(0);
                }
                binaryArray = binaryArray.concat(_tmpBinary);
            } else if (unicode >= 0x80 && unicode <= 0x7FF) {
                binaryArray = binaryArray.concat(_toUTF8Binary(2, _tmpBinary));
            } else if (unicode >= 0x800 && unicode <= 0xFFFF) {
                //UTF-8 3byte
                binaryArray = binaryArray.concat(_toUTF8Binary(3, _tmpBinary));
            } else if (unicode >= 0x10000 && unicode <= 0x1FFFFF) {
                //UTF-8 4byte
                binaryArray = binaryArray.concat(_toUTF8Binary(4, _tmpBinary));
            } else if (unicode >= 0x200000 && unicode <= 0x3FFFFFF) {
                //UTF-8 5byte
                binaryArray = binaryArray.concat(_toUTF8Binary(5, _tmpBinary));
            } else if (unicode >= 4000000 && unicode <= 0x7FFFFFFF) {
                //UTF-8 6byte
                binaryArray = binaryArray.concat(_toUTF8Binary(6, _tmpBinary));
            }
        }

        var extra_Zero_Count = 0;
        for (var i = 0, len = binaryArray.length; i < len; i += 6) {
            var diff = i + 6 - len;
            if (diff == 2) {
                extra_Zero_Count = 2;
            } else if (diff == 4) {
                extra_Zero_Count = 4;
            }
            //if(extra_Zero_Count > 0){
            //	len += extra_Zero_Count+1;
            //}
            var _tmpExtra_Zero_Count = extra_Zero_Count;
            while (--_tmpExtra_Zero_Count >= 0) {
                binaryArray.push(0);
            }
            base64_Index.push(_toDecimal(binaryArray.slice(i, i + 6)));
        }

        var base64 = '';
        for (var i = 0, len = base64_Index.length; i < len; ++i) {
            base64 += BASE64_MAPPING[base64_Index[i]];
        }

        for (var i = 0, len = extra_Zero_Count / 2; i < len; ++i) {
            base64 += '=';
        }
        return base64;
    },
    /**
     *BASE64  Decode for UTF-8
     */
    decode: function decode(_base64Str) {
        var _len = _base64Str.length;
        var extra_Zero_Count = 0;
        /**
         *计算在进行BASE64编码的时候，补了几个0
         */
        if (_base64Str.charAt(_len - 1) == '=') {
            //alert(_base64Str.charAt(_len-1));
            //alert(_base64Str.charAt(_len-2));
            if (_base64Str.charAt(_len - 2) == '=') {
                //两个等号说明补了4个0
                extra_Zero_Count = 4;
                _base64Str = _base64Str.substring(0, _len - 2);
            } else {
                //一个等号说明补了2个0
                extra_Zero_Count = 2;
                _base64Str = _base64Str.substring(0, _len - 1);
            }
        }

        var binaryArray = [];
        for (var i = 0, len = _base64Str.length; i < len; ++i) {
            var c = _base64Str.charAt(i);
            for (var j = 0, size = BASE64_MAPPING.length; j < size; ++j) {
                if (c == BASE64_MAPPING[j]) {
                    var _tmp = _toBinary(j);
                    /*不足6位的补0*/
                    var _tmpLen = _tmp.length;
                    if (6 - _tmpLen > 0) {
                        for (var k = 6 - _tmpLen; k > 0; --k) {
                            _tmp.unshift(0);
                        }
                    }
                    binaryArray = binaryArray.concat(_tmp);
                    break;
                }
            }
        }

        if (extra_Zero_Count > 0) {
            binaryArray = binaryArray.slice(0, binaryArray.length - extra_Zero_Count);
        }

        var unicode = [];
        var unicodeBinary = [];
        for (var i = 0, len = binaryArray.length; i < len;) {
            if (binaryArray[i] == 0) {
                unicode = unicode.concat(_toDecimal(binaryArray.slice(i, i + 8)));
                i += 8;
            } else {
                var sum = 0;
                while (i < len) {
                    if (binaryArray[i] == 1) {
                        ++sum;
                    } else {
                        break;
                    }
                    ++i;
                }
                unicodeBinary = unicodeBinary.concat(binaryArray.slice(i + 1, i + 8 - sum));
                i += 8 - sum;
                while (sum > 1) {
                    unicodeBinary = unicodeBinary.concat(binaryArray.slice(i + 2, i + 8));
                    i += 8;
                    --sum;
                }
                unicode = unicode.concat(_toDecimal(unicodeBinary));
                unicodeBinary = [];
            }
        }
        var ty_str = '';
        for (var i = 0, len = unicode.length; i < len; ++i) {
            ty_str += String.fromCharCode(unicode[i]);
        }
        return ty_str;
    }
};
exports.default = ybBase64;

/***/ })
/******/ ]);